<template>
	<view>
		<view class="background pb20">
			<navbar :back="true" :backgroundColor="background" :scrollTop="scrollTop" :title="$params.name + '搜索列表'"
				titleColor="#fff">
			</navbar>
			<view class="px20 mt30 mb10">
				<u-search placeholder="请输入搜索内容" :show-action="false" bg-color="#fff" :search-icon-color="$zs"
					height="76" placeholder-color="#B7B5B5" v-model="keywords"></u-search>
			</view>
			<screenList v-model="listParams" @input="getList()" :hospitalList="data.hospital_type" :serviceList="data.sort" class="color-fff"
				:type="$params.type" />
		</view>
		<goodsList v-if="$params.type=='fu'" :list="list" />
		<hospitalList v-if="$params.type=='yy'" :list="list" />
		<orgList v-if="$params.type=='pzs'" :list="list" tch />
		<orgList v-if="$params.type=='pzjg'" :list="list" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollTop: 0,
				background: {
					backgroundImage: 'linear-gradient(180deg, #00C2CF 0%, #1ED2BE 100%)',
				},

				keywords: '',
				list: '',
				listParams: {
					hospital_type: '全部医院', //医院类型
					service_id: '', //项目id
					price: '', //syn=综合价格,asc=由低到高,desc=由高到低
					distance: '', //	字符串	非必填	-	-	综合距离:asc=由近到远,desc=由远到近
					sale: 'syn', //销量 syn=综合',,asc=由低到高,desc=由高到低
				},

				data: '',

				num: 0
			};
		},
		watch: {
			keywords(e) {
				if (this.num) {
					this.$u.debounce(this.getList, 500)
				}
			},
		},
		onLoad(e) {
			this.keywords = e.keywords
			uni.setNavigationBarTitle({
				title: e.name || '' + '搜索列表'
			})
			this.getList()
			setTimeout(() => {
				this.num = 1
			}, 500)
			this.getData()
		},
		methods: {
			getData() {
				this.$request('/member/index/index').then(res => {
					this.data = res.data
				})
			},
			getList(e) {
				let data = this.$params
				e == 'down' ? this.page++ : this.page = 1
				let location = this.$getCache('location')
				let params = {
					page: this.page,
					longitude: location.longitude || '', //	字符串	非必填	-	-	用户当前经度
					latitude: location.latitude || '', //	字符串	非必填	-	-	用户当前纬度
					keyword: this.keywords, //	字符串	非必填	-	-	搜索关键词
					city_id: this.$getCache('myAdd')?.id || "", //	整型	必填	-	-	用户当前选择城市id

					...this.listParams,
					// hospital_type: this.hospital_type || '全部医院', //医院类型
					// service_id: this.service?.id || '', //项目id
					// price: this.price?.id || '', //syn=综合价格,asc=由低到高,desc=由高到低
					// distance: '', //	字符串	非必填	-	-	综合距离:asc=由近到远,desc=由远到近
					// sort: 'syn', //syn=综合,sale=销量,price_asc=价格由低到高,price_desc=价格由高到低
				}
				if (!params.city_id) return this.$msg('请选择地址')
				this.$request(data.api, params).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			},
		},
		onPageScroll: function(e) {
			this.scrollTop = e.scrollTop
		},
	}
</script>

<style lang="scss">
	.background {
		background: linear-gradient(180deg, #00C2CF 0%, #1ED2BE 100%),
	}
</style>
